home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / lists / mint / l_1199 / 1724 < prev    next >
Encoding:
Internet Message Format  |  1994-08-27  |  2.1 KB

  1. Date: Wed, 20 Jul 1994 06:55:29 -0400
  2. From: "Nicholas S Castellano" <entropy@terminator.rs.itd.umich.edu>
  3. To: mint@terminator.rs.itd.umich.edu
  4. Subject: INIT: PID 1
  5.  
  6. I've grown tired of 'init' always having a different PID depending on what
  7. has loaded before it.  Here's a simple patch to set it up so that the INIT
  8. process always has PID 1 even if it isn't the first thing to run.
  9.  
  10. The patch is relative to an "h6"-patched MiNT 1.10.
  11.  
  12. diff -u orig/main.c ./main.c
  13. --- orig/main.c    Tue Jul 19 04:40:40 1994
  14. +++ ./main.c    Wed Jul 20 06:20:28 1994
  15. @@ -882,6 +882,9 @@
  16.  /* run any programs appearing after us in the AUTO folder */
  17.      run_auto_prgs();
  18.  
  19. +/* prepare to run the init program as PID 1. */
  20. +    set_pid_1();
  21. +
  22.  /* run the initial program */
  23.  /* if that program is in fact GEM, we start it via exec_os, otherwise
  24.   * we do it with Pexec.
  25. diff -u orig/proto.h ./proto.h
  26. --- orig/proto.h    Wed Jul 20 06:34:38 1994
  27. +++ ./proto.h    Wed Jul 20 06:33:12 1994
  28. @@ -307,6 +307,7 @@
  29.  MEMREGION *addr2mem P_((virtaddr a));
  30.  PROC *pid2proc P_((int pid));
  31.  int newpid P_((void));
  32. +int set_pid_1 P_((void));
  33.  void zero P_((char *place, long size));
  34.  void * ARGS_ON_STACK kmalloc P_((long size));
  35.  void *kcore P_((long size));
  36. diff -u orig/util.c ./util.c
  37. --- orig/util.c    Tue Jul 19 04:41:28 1994
  38. +++ ./util.c    Wed Jul 20 06:20:18 1994
  39. @@ -49,10 +49,10 @@
  40.   * return a new pid
  41.   */
  42.  
  43. +static int _maxpid = 2;
  44.  int
  45.  newpid()
  46.  {
  47. -    static int _maxpid = 1;
  48.      int i;
  49.  #ifndef NDEBUG
  50.      int j = 0;
  51. @@ -60,12 +60,24 @@
  52.  
  53.      do {
  54.          i = _maxpid++;
  55. -        if (_maxpid >= 1000) _maxpid = 1;
  56. +        if (_maxpid >= 1000) _maxpid = 2;
  57.          assert(j++ < 1000);
  58.      } while (pid2proc(i));
  59.  
  60.      return i;
  61.  }
  62. +
  63. +/*
  64. + * set up to run the init program as PID 1
  65. + */
  66. +int
  67. +set_pid_1()
  68. +{
  69. +    if (pid2proc(1)) /* should never happen, only called once */
  70. +        return -1;
  71. +    _maxpid = 1;
  72. +    return 0;
  73. +}
  74.  
  75.  /*
  76.   * zero out a block of memory, quickly; the block must be word-aligned,
  77.  
  78. --
  79. entropy -- it's not just a good idea, it's the second law.
  80. Personal mail:      entropy@gnu.ai.mit.edu
  81. MiNT library mail:  entropy@terminator.rs.itd.umich.edu
  82. "what do you have against octal?" -jrb
  83.  
  84.